package com.showtao.front.repository;

import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import com.showtao.front.domain.MobileOrder;
/**
 * 
 * @author Fanxin Zeng
 *
 */

public interface MobileOrderRepository extends JpaRepository<MobileOrder,Long>{

	@Query("select m from MobileOrder m where m.mobile= ?1 and date_format(m.createdAt,'%Y-%m-%d') >= ?2 and date_format(m.createdAt,'%Y-%m-%d') <= ?3 order by m.createdAt desc")
	List<MobileOrder> findMobileOrderByMobileAndCreatedDate(String mobile, String startDate, String endDate);
	
	@Query("select m from MobileOrder m where m.mobile= ?1 and date_format(m.createdAt,'%Y-%m-%d') >= ?2 and date_format(m.createdAt,'%Y-%m-%d') <= ?3")
	Page<MobileOrder> findMobileOrderPC(String mobile, String startDate, String endDate, Pageable pageable);
}
